from ivic.core import Config, project_path
from ivic.core import Logging
from ivic.vmcweb.VMCWebServer import VMCWebServer 

logger = Logging.get_logger('ivic.vmcweb.Plugin')

__obj = None

def init(daemon_config):
    config = Config.load(project_path('/etc/ivic/vmc.yaml'))
    # this should dispatch 'ivic.vmc.*' to individual log file??? don't understat, gengjp, 0427
    # vmcweb shares the same log file with vmc???
    Logging.get_logger('ivic.vmcweb.Plugin', filename = config['log_file'])

    logger.debug('initializing %s' % __name__)
    global __obj
    if __obj:
        logger.error('reinitialized is not supported')
        return

    __obj = VMCWebServer()

def fini():
    global __obj 
    del __obj

def soap_mods():
    return {}

def wsgi_mods():
    global __obj
    return {'/vmcweb': __obj}
